<template>
	<view>
		<view class="top cflex">
			<view class="top_item" :class="type==1?'active':''" @tap="change(1)">
				全部
			</view>
			<view class="top_item" :class="type==2?'active':''" @tap="change(2)">
				审核中
			</view>
			<view class="top_item" :class="type==3?'active':''" @tap="change(3)">
				审核成功
			</view>
			<view class="top_item" :class="type==4?'active':''" @tap="change(4)">
				审核失败
			</view>
			
		</view>

		<block v-for="(item,index) in list">
			<view class="item flex">
				<view class="item_top cflex">
					<view class="orderNum">
						订单编号：{{item.order_num}}
					</view>
					<view class="status_text">
						{{item.status_text}}
					</view>
				</view>
				<view class="item_mid cflex">
					<image :src="item.images" mode=""></image>
					<view class="goods">
						<view class="goodsName">
							{{item.name}}
						</view>
						<view class="label">
							{{item.type_name}}
						</view>
						<view class="price">
							出厂价：{{item.factory_price}}元
						</view>
						<view class="count">
							购买件数：{{item.num}}件
						</view>
					</view>
				</view>
				<view class="item_bottom cflex ">
					<view class="button1 " @tap="call">
						联系客服
					</view>
					<view class="button3 " v-if="item.status_text=='已发货'">
						填写物流
					</view>
					<!-- <view class="button3 " v-if="item.status_text=='已发货'">
						查看物流
					</view> -->
					<view class="button3 " v-if="item.status_text=='已发货'" :data-order_id="item.order_id" @tap="takeOrder">
						确认收货
					</view>
					<view class="button3 " v-if="item.status_text=='待发货'" :data-order_id="item.order_id" @tap="sort">
						提醒发货
					</view>
					<view class="button3 " v-if="item.status_text=='待评价'" :data-order_id="item.order_id" @tap="">
						去评价
					</view>
					<view class="button2 " :data-order_id="item.order_id" @tap="todetail">
						编辑
					</view>
				</view>
			</view>
		</block>

		
		

	</view>
</template>

<script>
	import {
		ajax
	} from '../../ajax.js';
	export default {
		data() {
			return {
				zz: false,
				callModel: false,
				type: 1,
				DefaultPhone: '',
				firstNum: 1,
				num: 10,
				list: []
			}
		},
		onLoad(e) {
			let that = this
			that.type = e.type
			that.getlist()
			that.getDefaultPhone()

		},
		methods: {
			change(e) {
				let that = this
				that.type = e
			},
			callModelFalse() {
				let that = this
				that.callModel = false
				that.zz = false
			},
			tocall() {
				let that = this
				let phone = that.DefaultPhone
				uni.makePhoneCall({
					phoneNumber: phone //仅为示例
				});
				that.zz = false
				that.callModel = false
			},
			call() {
				let that = this
				that.zz = true
				that.callModel = true
			},
			getDefaultPhone() {
				let that = this
				ajax({
					url: 'order/getDefaultPhone',
					data: {

					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						console.log("token", res.data.data)
						that.DefaultPhone = res.data.data
					},
					error: function() {

					}
				});
			},
			getlist() {
				let that = this
				let status = that.type
				let firstNum = that.firstNum
				let num = that.num
				let token = uni.getStorageSync('token')
				ajax({
					url: 'goods/getMyInquiry',
					data: {
						token: token,
						firstNum: firstNum,
						num: num,
						status: status
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						console.log("token", res.data.data.data)
						that.list = res.data.data.data
					},
					error: function() {

					}
				});
			},
			sort(e) {
				let that = this
				let order_id = e
				console.log(order_id)
				ajax({
					url: 'order/sort',
					data: {
						//token: uni.getStorageSync('token'),
						order_id: order_id
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						uni.showToast({
							title: "提醒发货成功"
						})
					},
					error: function() {

					}
				});
			},
			takeOrder(e) {
				let that = this
				let order_id = e
				console.log(order_id)
				ajax({
					url: 'order/takeOrder',
					data: {
						token: uni.getStorageSync('token'),
						order_id: order_id
					},
					header: {
						'content-type': 'application/json' //自定义请求头信息
					},
					method: 'POST',
					success: function(res) {
						uni.showToast({
							title: "确认收货成功"
						})
					},
					error: function() {

					}
				});
			},
			todetail(e) {
				let that = this
				let order_id = e
				console.log(order_id)
				uni.navigateTo({
					url: ''
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: #F7F7F7;
	}

	.zz {
		width: 750rpx;
		height: 100%;
		background-color: rgba(0, 0, 0, 0.5);
		position: absolute;
		top: 0;
	}

	.callModel {
		width: 620rpx;
		height: 276rpx;
		background-color: #FFFFFF;
		position: absolute;
		top: 471rpx;
		left: 65rpx;
		border-radius: 20rpx;
	}

	.callModel_tit {
		text-align: center;
		font-size: 28rpx;
		color: #333333;
		margin-top: 18rpx;
	}

	.callModel_Text {
		text-align: center;
		font-size: 30rpx;
		color: #FF7427;
		margin-top: 60rpx;
	}

	.callModel_bottom>view {
		width: 50%;
		text-align: center;
		height: 88rpx;
		margin-top: 32rpx;
		line-height: 88rpx;
		font-size: 28rpx;
	}

	.cancel {
		background-color: #F7F7F7;
		border-bottom-left-radius: 20rpx;
	}

	.tocall {
		color: #FFFFFF;
		background-color: #FF7427;
		border-bottom-right-radius: 20rpx;
	}

	.top {
		width: 95%;
		margin: 0 auto;
		justify-content: space-between;
		margin-bottom: 44rpx;
	}

	.active {
		color: #FF7427;
		border-bottom: 1px solid #FF7427;
		padding-bottom: 5rpx;
	}

	.top_item {
		font-size: 28rpx;
	}

	.item {
		width: 712rpx;
		height: 333rpx;
		background-color: #FFFFFF;
		margin: 22rpx auto;
	}

	.item_top {
		justify-content: space-between;
		width: 95%;
		margin: 0 auto;
		padding-top: 23rpx;
	}

	.orderNum {
		font-size: 28rpx;
		color: #333333;
	}

	.status_text {
		font-size: 24rpx;
		color: #FF7427;
	}

	.item_mid {
		width: 95%;
		margin: 0 auto;
		margin-top: 20rpx;
	}

	.item_mid>image {
		width: 169rpx;
		height: 169rpx;
		background-color: #000000;
		border-radius: 10rpx;
	}

	.goods {
		margin-left: 29rpx;

	}

	.goodsName {
		font-size: 28rpx;
		color: #333333;
	}

	.label {
		font-size: 24rpx;
		color: #555555;
		margin-top: 10rpx;
	}

	.price {
		font-size: 24rpx;
		color: #D50000;
		margin-top: 15rpx;
	}

	.count {
		font-size: 24rpx;
		color: #555555;
		margin-top: 10rpx;
	}

	.item_bottom {
		justify-content: flex-end;
		margin-top: 20rpx;
	}

	.item_bottom>view {
		margin-right: 20rpx;
		width: 160rpx;
		height: 48rpx;
		border-radius: 100rpx;
		font-size: 28rpx;
		line-height: 48rpx;
		text-align: center;
	}

	/* 联系客服 */
	.button1 {
		border: 1px solid #999999;
		color: #999999;
	}

	/* 查看订单 */
	.button2 {
		background-color: #FF7427;
		color: #FFFFFF;
	}

	/* 提醒发货 填写物流 查看物流 去评价*/
	.button3 {
		border: 1px solid #FF7427;
		color: #FF7427;
	}
</style>
